<template>
	<view class="header-bg-image header-bg">
		<view style="height: 50rpx;"></view>
		<view class="padding-30">
			<view class="margin-30-0 flex-around" @click="$tools.navigateBack()">
				<u-icon name="arrow-left" color="#333333" size="20"></u-icon>
				<view class="fontSize-18 color-000 flex1 text-center">我的祈福</view>
				<view style="width: 40rpx;"></view>
			</view>
			<view class="margin-30-0">
				<u-tabs :list="list1" lineColor="#967C5E" @click="chooseTabs"></u-tabs>
			</view>

			<view class="border-radius20 bg-fff margin-bottom30" v-for="(item,index) in list" :key="index"
				style="overflow: hidden;box-shadow: 2px 2px 2px #cccccc;" @click="goToUrls(item.id)">
				<image class="img-list" :src="item.goods.image" mode=""></image>
				<view class="flex-between padding-30">
					<view class="fontSize-15 color-704234">{{item.goods.title}}</view>
					<view class="fontSize-15 color-704234">￥{{item.goods.price}}</view>
				</view>
			</view>
			<!-- <view class="shopping-list">
				<view class="shopping-item" v-for="(item,index) in list" :key="index" @click="goToUrls(item.id)">
					<image class="shopping-item-image" :src="item.goods.image"></image>
					<view class="shopping-item-text">{{item.goods.title}}</view>
					<view class="flex-between">
						<view class="shopping-item-price">￥<text style="font-size: 38rpx;">{{item.goods.price}}</text></view>
					</view>
				</view>
			</view> -->
			<u-empty v-if="list.length == 0" mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png"
				width="150px" height="150px" text="列表为空" textSize="18">
			</u-empty>
			<view style="padding-bottom: 100rpx;">
				<u-loadmore v-if="loading" status="loading" />
				<u-loadmore v-if="isLastPage" status="nomore" />
			</view>
		</view>
	</view>
</template>

<script>
	import goodsItem from "@/components/goods/goods.vue"
	export default {
		components: {
			goodsItem
		},
		data() {
			return {
				list1: [{
						name: '待祈福',
						status: 0
					},
					{
						name: '已祈福',
						status: 1
					}
				],
				status: 0,
				page: 1,
				limit: 10,
				list: [],
				isLastPage: false,
				loading: false,
			}
		},
		onShow() {
			this.page = 1
			this.limit = 10
			this.list = []
			this.getScoreList()
		},
		// 刷新 上拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.isLastPage = false
			this.list = []
			this.getScoreList().finally(() => {
				// 停止当前页面下拉刷新
				uni.stopPullDownRefresh();
			});
		},
		// 加载下一页 下拉加载
		onReachBottom() {
			if (this.list.length >= this.page * this.limit) {
				this.isLastPage = false;
				this.page += 1;
				this.getScoreList();
			} else {
				this.isLastPage = true
			}
		},
		methods: {
			goToUrls(id) {
				this.$tools.navigateTo('/pages/mine/mine-list/prayer-record?id=' + id)
			},
			// 选择tabs
			chooseTabs(e) {
				this.list1Name = e.name
				this.status = e.status
				this.page = 1
				this.limit = 10
				this.list = []
				this.getScoreList()
			},
			// 列表
			async getScoreList() {
				this.$http.post(this.$api.pray_list, {
					page: this.page,
					limit: this.limit,
					status: this.status
				}, {
					token: true
				}).then(res => {
					this.list = [...this.list, ...res.data]
				}).finally(() => {
					// 停止当前页面下拉刷新
					uni.stopPullDownRefresh();
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.img-list{
		width: 100%;
		height: 320rpx;
		flex-shrink: 0;
		border-radius: 20;
		// border: 2px solid  #967C5E;
	}
	.buy-Item {
		width: 98rpx;
		height: 48rpx;
		background: #967C5E;
		font-weight: 400;
		font-size: 24rpx;
		color: #FFFFFF;
		border-radius: 33rpx 33rpx 33rpx 33rpx;
	}

	.shopping-item-price {
		font-weight: 400;
		font-size: 26rpx;
		color: #FE3232;
		margin-top: 20rpx;
	}

	.shopping-item-text1 {
		font-weight: 400;
		font-size: 12px;
		color: #999999;
		margin: 10rpx 0;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;

	}

	.shopping-item-text {
		font-weight: 500;
		font-size: 15px;
		color: #333333;
		margin: 10rpx 0;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;

	}

	.shopping-item-image {
		width: 325rpx;
		height: 325rpx;
		background: #EBF4FF;
		border-radius: 14rpx 14rpx 0rpx 0rpx;
		flex-shrink: 0;
	}

	.shopping-item:nth-child(2n) {
		margin-right: 0;
	}

	.shopping-item {
		width: 46%;
		padding: 10rpx;
		background-color: #ffffff;
		border-radius: 14rpx;
		display: flex;
		justify-content: center;
		flex-direction: column;
		margin: 0 2% 30rpx 0;
	}

	.shopping-list {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		// margin-top: 30rpx;
	}
</style>